'use server';

import { headers } from 'next/headers';
import { getURLObj } from '@/utils/common';
import { gfetch } from '@/utils/back/fetch';

export async function getAppConfigSA() {
  const res = await gfetch(
    `${process.env.NEXT_PUBLIC_CONFIG_CENTER_DOMAIN}/api/app/config?appid=2&env=production`,
    {
      cache: 'no-cache',
      headers: {
        'x-app-secret': '8d121dc1072dfc9fa2a8aa28fcbf9b6a',
      },
    }
  );

  return res;
}

export async function getAuthorListSA() {
  const headersObj = headers();

  const authApi = getURLObj(
    '/api/author',
    headersObj.get('origin') || headersObj.get('referer')!
  ).toString();
  const res = await gfetch(authApi);

  return res;
}
